
local mt = ac.buff['光环']
mt.cover_type = 1
mt.cover_max = 0
mt.pulse = 0.25
mt.aura_time = 1      --维持时间
mt.aura_area = 900
mt.area_type = 'ally'    --敌人/友军/全部 enemy/ally/all
mt.aura_point = nil   --光环点
mt.buff_name = ''   --子效果名
mt.keep = true      --是否保持
mt.model = nil
mt.ref = 'origin'


function mt:on_add()
    local hero = self.owner
    self.buff_data = self.buff_data or {}
    self.buff_data.time = self.aura_time
    self.buff_data.is_aura = true
    self.buff_data.source = hero
    if not self.selector then
        self.selector = ac.selector('unit'):range(self.aura_point or hero,self.aura_area)
        if self.area_type=='ally' then
            self.selector = self.selector:ally(hero)
        elseif self.area_type=='enemy' then
            self.selector = self.selector:enemy(hero)
        end
    end
	if self.model then
		self:gc(hero:add_effect(self.model,self.ref))
	end
end

function mt:on_pulse()
    local hero = self.owner
    local update = {}
    self.has_unit = self.has_unit or {}
    if self.selector and hero:is_alive() then
        for u in self.selector:loop() do
            if self.has_unit[u] and self.has_unit[u]:get_remaining()>0 then
                update[u] = self.has_unit[u]
                update[u]:set_remaining(self.aura_time)
            else
                update[u] = u:add_buff(self.buff_name)(table.copy(self.buff_data))
            end
            
        end
    end
    self.has_unit = update
end


